package com.woniuxy.thred.others;

/**
 * description: VolatileTest <br>
 * date: 2022/2/6 6:18 下午 <br>
 * author: shesaifei <br>
 * version: 1.0 <br>
 */

/**
 * volatile用于保证数据同步，也是就是可见性
 */
public class VolatileTest {
    private volatile static int num = 0;

    public static void main(String[] args) throws InterruptedException {
        new Thread(() -> {
            //此处不要写代码
            while (num == 0) {

            }
        }).start();

        Thread.sleep(1000);
        num = 1;
    }
}
